<?php
require_once('../scripts/db.php');
include("includes/functions.php");

if ($_POST) {

$user = mysql_real_escape_string($_POST['username']);

$query = "DELETE FROM `papptweet` WHERE username = '$user'";
mysql_query($query) or die(mysql_error());

$url = "http://twitter.com/friendships/destroy/". $user .".json";

$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

header("Location: unsubthanks.php");

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TwitterPlan | Sorry to see you go</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="main">
<img src="images/logo.jpg" alt="TwittertPlan Alpha" width="315" height="62" />
<img src="images/bird.jpg" alt="TwitterPlan Mascot" width="228" height="238" id="mascot" />
<div id="thankswrapper">
<h2>Sorry to see you go</h2>
<p>To confirm that you want to unsubscribe from this service, please click the button below and we'll never bother you again, promise!</p>
<form action="" method="post" class="changeform">
<input type="hidden" name="username" value="<?php echo $_GET['user']; ?>" />
  <button type="submit" id="unsub"><img src="images/unsubbutton.gif" alt="Unsubscribe" width="163" height="46" /></button>   
</form>
</div>
</div>
<div id="footer">
<p>powered by: <a href="http://www.twitter.com"><img src="images/twitter.gif" alt="twitter" border="0" /></a> <a href="http://www.planningalerts.com"><img src="images/planningalerts.gif" alt="Planning Alerts" border="0" /></a> built by: <a href="http://www.lichfielddc.gov.uk"><img src="images/ldc.gif" alt="Lichfield District Council" border="0" /></a> made pretty by <a href="http://www.lincoln.gov.uk"><img src="images/lincoln.gif" alt="City of Lincoln Council" border="0" /></a> and <a href="http://twitter.com/michaeldpollard">@MichaelDPollard</a></p>
</div>
</div>
<style type='text/css'>@import url('http://s3.amazonaws.com/getsatisfaction.com/feedback/feedback.css');</style>
<script src='http://s3.amazonaws.com/getsatisfaction.com/feedback/feedback.js' type='text/javascript'></script>
<script type="text/javascript" charset="utf-8">
  var tab_options = {}
  tab_options.placement = "left";  // left, right, bottom, hidden
  tab_options.color = "#222"; // hex (#FF0000) or color (red)
  GSFN.feedback('http://getsatisfaction.com/twitterplan/feedback/topics/new?display=overlay&style=question', tab_options);
</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-511839-14");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
